package com.lms.util.WeixinUtil;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

public class XmlUtil {
    public static Map<String,String> parseStreamToMap(InputStream in) throws JDOMException, IOException {
        Map<String, String> params = new HashMap<>();
        Document doc = new SAXBuilder().build(in);
        Element rootElement = doc.getRootElement();
        params.put("ToUserName",rootElement.getChildText("ToUserName"));
        params.put("FromUserName",rootElement.getChildText("FromUserName"));
        params.put("CreateTime",rootElement.getChildText("CreateTime"));
        params.put("MsgType",rootElement.getChildText("MsgType"));
        params.put("Event",rootElement.getChildText("Event"));
        params.put("EventKey",rootElement.getChildText("EventKey"));
        params.put("Ticket",rootElement.getChildText("Ticket"));
        params.put("MsgID",rootElement.getChildText("MsgID"));
        params.put("Status",rootElement.getChildText("Status"));
        return params;
    }
}
